<!--
	

	This updates the table of costs
-->
<?php
require("libraries\CostLib.php");
	session_start();
	if((!isset($_SESSION['mainType']) && (!isset($_SESSION['subType'])))){
		header("Location:ViewAnalysisCosts.php");
	}
	
	$acon = mysql_connect('localhost','login','login') or die('Could not connect: ' . mysql_error());
	mysql_select_db('casl') or die(mysql_error());
	echo "|".$_SESSION['subType']."|";
	$result = mysql_query("SELECT main_type, sample_type, analysis_type, cost FROM cost_analysis WHERE sample_type='".$_SESSION['subType']."'",$acon);
	
	while($entry = mysql_fetch_row($result)){
		$value = $_POST[str_replace(".","_",str_replace(" ","_",$entry[2]))];
		echo $value."</br>";
		$next = updateCost($entry[0],$entry[1],$entry[2],$value,'casl','localhost','editcost','editcost');				
	}
	
	mysql_close($acon);
	$location = "Location: viewCost.php?success=true&mainType=".str_replace(" ","%20",$_SESSION["mainType"])."&subType=".str_replace(" ","%20",$_SESSION["subType"]);
	echo $location;
	header($location);
?>